package com.huang.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.huang.dao.WorkDao;
import com.huang.domain.Work;
import com.huang.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WorkServiceImpl implements WorkService {
    @Autowired
    private WorkDao workDao;


    @Override
    public void add(Work work) {
        workDao.insert(work);
    }

    @Override
    public Work findByFilename(String filename) {
        return workDao.selectByFilename(filename);
    }

    @Override
    public PageInfo<Work> findByPage(int pageNum, int pageSize) {
        // 开始分页
        PageHelper.startPage(pageNum, pageSize);//---关键代码，其后第一条查询自动分页
        // 调用dao
        List<Work> list = workDao.findAll();
        return new PageInfo<>(list);
    }


}
